package com.shop.admin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.admin.entity.Organization;
import com.shop.admin.entity.ShopIndent;
import com.shop.admin.orgvo.SchoolOrgGeneralReport;
import com.shop.admin.orgvo.ThisOrderDataVo;
import com.shop.admin.vo.DataVo;
import com.shop.admin.vo.IndentVo;
import com.shop.admin.vo.IzationVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ShopIndentDao extends BaseMapper<ShopIndent> {
    Page<IndentVo> queryPage(@Param("page") Page page,  Map<String, Object> params );

    List<IzationVo> getDataIzation(@Param("params")Map<String, Object> params);

    //@Select("SELECT SUM(prices) pricesCount, SUM(prices - cost) profits, COUNT(*) saleCount FROM shop_indent d RIGHT JOIN ( SELECT b.indent_id, SUM(price_cost * order_num)  cost FROM shop_goods b LEFT JOIN shop_order c ON b.order_id = c.order_id WHERE b.indent_id IN ( SELECT indent_id FROM shop_indent WHERE  indent_status = 3) GROUP BY b.indent_id) a ON a.indent_id = d.indent_id AND d.org_id = #{params.orgId}")
    DataVo getDataCount(@Param("params")Map<String, Object> params);

    DataVo getSchoolDataCount(@Param("integerList") List<Integer> integerList);

    List<IzationVo> getSchoolDataIzation(@Param("integerList") List<Integer> integerList);

    List<SchoolOrgGeneralReport> schoolOrgGeneralReportList(@Param("orgId") List<Integer> orgId);

    Page<SchoolOrgGeneralReport> schoolOrgGeneralReportPage(@Param("page") Page<SchoolOrgGeneralReport> page, @Param("orgId") List<Integer> orgId);

    ThisOrderDataVo getThisYearOrderDataSnacks(@Param("orgId") List<Integer> orgId);

    ThisOrderDataVo getLastYearOrderDataSnacks(@Param("orgId") List<Integer> orgId);

    @Select("SELECT count( DISTINCT user_id ) FROM shop_indent")
    Integer efficaciousUserNum();
}
